<template>
  <div class="sub">
    <!-- <h3>当前count:{{ count }}</h3> -->
    <h3>{{ show }}</h3>
    <button @click="btn1">-1</button>
    <button @click="btn2">-N</button>
    <!-- 上面也可以直接写成@click="sub" -->
    <button @click="subasync">异步-1</button>
    <button @click="subNasync(3)">异步-N</button>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions, mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState(["count"]),
    ...mapGetters(["show"]),
  },
  methods: {
    ...mapMutations(["sub", "subN"]),
    ...mapActions(["subasync", "subNasync"]),
    btn1() {
      this.sub();
    },
    btn2() {
      this.subN(3);
    },
  },
};
</script>
